/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var MonthSchema = new mongoose.Schema({
    mid      :{type:Number,index: true},//mid
    bid     :{type:Number,index: true},//书id
    uid     :{type:Number,index: true},//用户id
    month    :{type : Number},//月票
    startTime    :{type : Number}//时间
});

MonthSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Month').find(obj, callback).sort(obj1);
};
MonthSchema.statics.findFnLimit = function(obj,obj1,num1,callback) {
    return this.model('Month').find(obj).sort(obj1).limit(num1).exec(callback);
};
MonthSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Month').findOne(obj).sort(obj1).exec(callback);
};
MonthSchema.statics.findConut = function(obj,callback) {
    return this.model('Month').find(obj).count().exec(callback);
};

var MonthModel = db.model('Month', MonthSchema);

module.exports=MonthModel;